package com.ruoyi.user.service.impl;

import com.ruoyi.common.core.cg.pojo.Group;
import com.ruoyi.common.core.cg.result.Result;
import com.ruoyi.user.service.AiService;
import com.ruoyi.user.service.GroupService;
import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.chat.StreamingChatClient;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AiServiceImpl implements AiService {
    private final ChatClient client;
    @Autowired
    private AiServiceImpl(ChatClient chatClient, StreamingChatClient streamingChatClient){
        this.client = chatClient;
    }
    @Autowired
    private GroupService groupService;

    @Override
    public Result chat(String question) {
        Prompt prompt = new Prompt(new UserMessage(question));
        String answer = client.call(prompt).getResult().getOutput().getContent();
        return new Result(true,"回复成功",answer);
    }
    private String data(){
        List<Map<String, Object>> groupList = groupService.findAll();

        return "";
    }
}
